<?php
namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Activity extends Model
{
    public $table = 'activity';

    protected $fillable = [
    	'id',
        'title',
        'class_id',
        'user_number',
        'start_time',
        'end_time',
        'pic1',
        'pic2',
        'introduction',
        'content',
    ];

    public function class()
    {
        return $this->hasOne(ActivityClassif::class,'id','class_id');
    }

    public  function getStatusName(){
        $status = $this->getAttributeValue('status');
        switch ($status) {
            case 0:
                return '草稿';
                break;
            case 1:
                return '已发布';
                break;
            case 2:
                return '已结束';
                break;
            case 10:
                return '定时发布';
                break;
            default:
                return '未知状态';
                break;
        }
    }

}
